package ru.alt22.visor.php.unittests.core;

public class PHPTestCaseResult {

	public static final String ERROR       = "ERROR";
	public static final String NOT_RUNNED  = "NOT RUNNED";
	public static final String OK          = "OK";
	public static final String FAILS       = "FAILS";
	public static final String INCOMPLETED = "INCOMPLETED";

	private static final String NOT_RUNNED_ERROR_MESSAGE = "This test case have not runned yet.";

	private static PHPTestCaseResult notRunned = null;

	private String statusString;
	private String errorMessage;

	static {
		notRunned = new PHPTestCaseResult();
		notRunned.setStatusString(NOT_RUNNED);
		notRunned.setErrorMessage(NOT_RUNNED_ERROR_MESSAGE);
	}

	public static PHPTestCaseResult notRunned() {
		return notRunned;
	}

	public static PHPTestCaseResult error(String message) {
		PHPTestCaseResult result = new PHPTestCaseResult();
		result.setStatusString(ERROR);
		result.setErrorMessage(message);
		return result;
	}
	
	public static PHPTestCaseResult error(Throwable e) {
		return error(e.toString());
	}

	public void setStatusString(String statusString) {
		this.statusString = statusString;
	}

	public String getStatusString() {
		return statusString;
	}

	public boolean isPassed() {
		return getStatusString().equals(OK);
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

}